home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tk4.0 / tkCanvas.h < prev    next >
C/C++ Source or Header  |  1995-03-18  |  9KB  |  252 lines

  1. /*
  2.  * tkCanvas.h --
  3.  *
  4.  *    Declarations shared among all the files that implement
  5.  *    canvas widgets.
  6.  *
  7.  * Copyright (c) 1991-1994 The Regents of the University of California.
  8.  * Copyright (c) 1994-1995 Sun Microsystems, Inc.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * @(#) tkCanvas.h 1.36 95/03/18 16:47:07
  14.  */
  15.  
  16. #ifndef _TKCANVAS
  17. #define _TKCANVAS
  18.  
  19. #ifndef _TK
  20. #include "tk.h"
  21. #endif
  22.  
  23. /*
  24.  * The record below describes a canvas widget.  It is made available
  25.  * to the item procedures so they can access certain shared fields such
  26.  * as the overall displacement and scale factor for the canvas.
  27.  */
  28.  
  29. typedef struct TkCanvas {
  30.     Tk_Window tkwin;        /* Window that embodies the canvas.  NULL
  31.                  * means that the window has been destroyed
  32.                  * but the data structures haven't yet been
  33.                  * cleaned up.*/
  34.     Display *display;        /* Display containing widget;  needed, among
  35.                  * other things, to release resources after
  36.                  * tkwin has already gone away. */
  37.     Tcl_Interp *interp;        /* Interpreter associated with canvas. */
  38.     Tcl_Command widgetCmd;    /* Token for canvas's widget command. */
  39.     Tk_Item *firstItemPtr;    /* First in list of all items in canvas,
  40.                  * or NULL if canvas empty. */
  41.     Tk_Item *lastItemPtr;    /* Last in list of all items in canvas,
  42.                  * or NULL if canvas empty. */
  43.  
  44.     /*
  45.      * Information used when displaying widget:
  46.      */
  47.  
  48.     int borderWidth;        /* Width of 3-D border around window. */
  49.     Tk_3DBorder bgBorder;    /* Used for canvas background. */
  50.     int relief;            /* Indicates whether window as a whole is
  51.                  * raised, sunken, or flat. */
  52.     int highlightWidth;        /* Width in pixels of highlight to draw
  53.                  * around widget when it has the focus.
  54.                  * <= 0 means don't draw a highlight. */
  55.     XColor *highlightBgColorPtr;
  56.                 /* Color for drawing traversal highlight
  57.                  * area when highlight is off. */
  58.     XColor *highlightColorPtr;    /* Color for drawing traversal highlight. */
  59.     int inset;            /* Total width of all borders, including
  60.                  * traversal highlight and 3-D border.
  61.                  * Indicates how much interior stuff must
  62.                  * be offset from outside edges to leave
  63.                  * room for borders. */
  64.     GC pixmapGC;        /* Used to copy bits from a pixmap to the
  65.                  * screen and also to clear the pixmap. */
  66.     int width, height;        /* Dimensions to request for canvas window,
  67.                  * specified in pixels. */
  68.     int redrawX1, redrawY1;    /* Upper left corner of area to redraw,
  69.                  * in pixel coordinates.  Border pixels
  70.                  * are included.  Only valid if
  71.                  * REDRAW_PENDING flag is set. */
  72.     int redrawX2, redrawY2;    /* Lower right corner of area to redraw,
  73.                  * in pixel coordinates.  Border pixels
  74.                  * will *not* be redrawn. */
  75.     int confine;        /* Non-zero means constrain view to keep
  76.                  * as much of canvas visible as possible. */
  77.  
  78.     /*
  79.      * Information used to manage the selection and insertion cursor:
  80.      */
  81.  
  82.     Tk_CanvasTextInfo textInfo; /* Contains lots of fields;  see tk.h for
  83.                  * details.  This structure is shared with
  84.                  * the code that implements individual items. */
  85.     int insertOnTime;        /* Number of milliseconds cursor should spend
  86.                  * in "on" state for each blink. */
  87.     int insertOffTime;        /* Number of milliseconds cursor should spend
  88.                  * in "off" state for each blink. */
  89.     Tk_TimerToken insertBlinkHandler;
  90.                 /* Timer handler used to blink cursor on and
  91.                  * off. */
  92.  
  93.     /*
  94.      * Transformation applied to canvas as a whole:  to compute screen
  95.      * coordinates (X,Y) from canvas coordinates (x,y), do the following:
  96.      *
  97.      * X = x - xOrigin;
  98.      * Y = y - yOrigin;
  99.      */
  100.  
  101.     int xOrigin, yOrigin;    /* Canvas coordinates corresponding to
  102.                  * upper-left corner of window, given in
  103.                  * canvas pixel units. */
  104.     int drawableXOrigin, drawableYOrigin;
  105.                 /* During redisplay, these fields give the
  106.                  * canvas coordinates corresponding to
  107.                  * the upper-left corner of the drawable
  108.                  * where items are actually being drawn
  109.                  * (typically a pixmap smaller than the
  110.                  * whole window). */
  111.  
  112.     /*
  113.      * Information used for event bindings associated with items.
  114.      */
  115.  
  116.     Tk_BindingTable bindingTable;
  117.                 /* Table of all bindings currently defined
  118.                  * for this canvas.  NULL means that no
  119.                  * bindings exist, so the table hasn't been
  120.                  * created.  Each "object" used for this
  121.                  * table is either a Tk_Uid for a tag or
  122.                  * the address of an item named by id. */
  123.     Tk_Item *currentItemPtr;    /* The item currently containing the mouse
  124.                  * pointer, or NULL if none. */
  125.     double closeEnough;        /* The mouse is assumed to be inside an
  126.                  * item if it is this close to it. */
  127.     XEvent pickEvent;        /* The event upon which the current choice
  128.                  * of currentItem is based.  Must be saved
  129.                  * so that if the currentItem is deleted,
  130.                  * can pick another. */
  131.     int state;            /* Last known modifier state.  Used to
  132.                  * defer picking a new current object
  133.                  * while buttons are down. */
  134.  
  135.     /*
  136.      * Information used for managing scrollbars:
  137.      */
  138.  
  139.     char *xScrollCmd;        /* Command prefix for communicating with
  140.                  * horizontal scrollbar.  NULL means no
  141.                  * horizontal scrollbar.  Malloc'ed*/
  142.     char *yScrollCmd;        /* Command prefix for communicating with
  143.                  * vertical scrollbar.  NULL means no
  144.                  * vertical scrollbar.  Malloc'ed*/
  145.     int scrollX1, scrollY1, scrollX2, scrollY2;
  146.                 /* These four coordinates define the region
  147.                  * that is the 100% area for scrolling (i.e.
  148.                  * these numbers determine the size and
  149.                  * location of the sliders on scrollbars).
  150.                  * Units are pixels in canvas coords. */
  151.     char *regionString;        /* The option string from which scrollX1
  152.                  * etc. are derived.  Malloc'ed. */
  153.     int xScrollIncrement;    /* If >0, defines a grid for horizontal
  154.                  * scrolling.  This is the size of the "unit",
  155.                  * and the left edge of the screen will always
  156.                  * lie on an even unit boundary. */
  157.     int yScrollIncrement;    /* If >0, defines a grid for horizontal
  158.                  * scrolling.  This is the size of the "unit",
  159.                  * and the left edge of the screen will always
  160.                  * lie on an even unit boundary. */
  161.  
  162.     /*
  163.      * Information used for scanning:
  164.      */
  165.  
  166.     int scanX;            /* X-position at which scan started (e.g.
  167.                  * button was pressed here). */
  168.     int scanXOrigin;        /* Value of xOrigin field when scan started. */
  169.     int scanY;            /* Y-position at which scan started (e.g.
  170.                  * button was pressed here). */
  171.     int scanYOrigin;        /* Value of yOrigin field when scan started. */
  172.  
  173.     /*
  174.      * Information used to speed up searches by remembering the last item
  175.      * created or found with an item id search.
  176.      */
  177.  
  178.     Tk_Item *hotPtr;        /* Pointer to "hot" item (one that's been
  179.                  * recently used.  NULL means there's no
  180.                  * hot item. */
  181.     Tk_Item *hotPrevPtr;    /* Pointer to predecessor to hotPtr (NULL
  182.                  * means item is first in list).  This is
  183.                  * only a hint and may not really be hotPtr's
  184.                  * predecessor. */
  185.  
  186.     /*
  187.      * Miscellaneous information:
  188.      */
  189.  
  190.     Cursor cursor;        /* Current cursor for window, or None. */
  191.     char *takeFocus;        /* Value of -takefocus option;  not used in
  192.                  * the C code, but used by keyboard traversal
  193.                  * scripts.  Malloc'ed, but may be NULL. */
  194.     double pixelsPerMM;        /* Scale factor between MM and pixels;
  195.                  * used when converting coordinates. */
  196.     int flags;            /* Various flags;  see below for
  197.                  * definitions. */
  198.     int nextId;            /* Number to use as id for next item
  199.                  * created in widget. */
  200.     struct TkPostscriptInfo *psInfoPtr;
  201.                 /* Pointer to information used for generating
  202.                  * Postscript for the canvas.  NULL means
  203.                  * no Postscript is currently being
  204.                  * generated. */
  205. } TkCanvas;
  206.  
  207. /*
  208.  * Flag bits for canvases:
  209.  *
  210.  * REDRAW_PENDING -        1 means a DoWhenIdle handler has already
  211.  *                been created to redraw some or all of the
  212.  *                canvas.
  213.  * REDRAW_BORDERS -         1 means that the borders need to be redrawn
  214.  *                during the next redisplay operation.
  215.  * REPICK_NEEDED -        1 means DisplayCanvas should pick a new
  216.  *                current item before redrawing the canvas.
  217.  * GOT_FOCUS -            1 means the focus is currently in this
  218.  *                widget, so should draw the insertion cursor
  219.  *                and traversal highlight.
  220.  * CURSOR_ON -            1 means the insertion cursor is in the "on"
  221.  *                phase of its blink cycle.  0 means either
  222.  *                we don't have the focus or the cursor is in
  223.  *                the "off" phase of its cycle.
  224.  * UPDATE_SCROLLBARS -        1 means the scrollbars should get updated
  225.  *                as part of the next display operation.
  226.  * LEFT_GRABBED_ITEM -        1 means that the mouse left the current
  227.  *                item while a grab was in effect, so we
  228.  *                didn't change canvasPtr->currentItemPtr.
  229.  * REPICK_IN_PROGRESS -        1 means PickCurrentItem is currently
  230.  *                executing.  If it should be called recursively,
  231.  *                it should simply return immediately.
  232.  */
  233.  
  234. #define REDRAW_PENDING        1
  235. #define REDRAW_BORDERS        2
  236. #define REPICK_NEEDED        4
  237. #define GOT_FOCUS        8
  238. #define CURSOR_ON        0x10
  239. #define UPDATE_SCROLLBARS    0x20
  240. #define LEFT_GRABBED_ITEM    0x40
  241. #define REPICK_IN_PROGRESS    0x100
  242.  
  243. /*
  244.  * Canvas-related procedures that are shared among Tk modules but not
  245.  * exported to the outside world:
  246.  */
  247.  
  248. extern int        TkCanvPostscriptCmd _ANSI_ARGS_((TkCanvas *canvasPtr,
  249.                 Tcl_Interp *interp, int argc, char **argv));
  250.  
  251. #endif /* _TKCANVAS */
  252.